#include <iostream>
//#include <cstring>
using namespace std;
int n,m;
int a[10];
bool v[10];
void dfs(int x)
{
	if (x>n)
	{
		for (int i=1;i<=n;i++)
			printf("%d	",a[i]);
		printf("\n");
		return ;
	}
	for (int i=1;i<=n;i++ )
	{
		if (v[i]==0)
		{
			v[i] = true;
			a[x]=i;
			dfs(x+1);
			v[i] = false;
		}
	}
	 
} 
int main()
{
	cin >> n >> m;
	dfs(1); 
	return 0;
}
